<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>

  <style>
    .box {
      color:red;
      font-size: 40px;
    }
  </style>
</head>
<body>
  <h2 class="test">我是内容</h2>

  <script>
    var h2 = document.querySelector('h2')

    h2.onclick = function() {
      // this.style.color = 'red'
      // this.style.fontSize = '50px'

      // console.log( this.className )
      this.className = this.className + ' box'
    }
  </script>
</body>
</html>